package com.ruoyi.web.controller.ring.app;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.dto.GeneralSecondDTO;
import com.ruoyi.ring.service.IExerciseDetailSecondService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 锻炼二级页 （APP）
 */
@Slf4j
@RestController
@RequestMapping("/ring/app/ring_exercise_detail_second")
public class ExerciseDetailSecondController extends BaseController
{
    @Resource
    private IExerciseDetailSecondService secondService;
    /**
     * 二级页 开始锻炼列表页 app
     */
    @GetMapping("/query-exercise-info-list")
    public AjaxResult queryExerciseInfoList(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("开始锻炼列表页: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryExerciseInfoList(secondDTO));
    }

    /**
     * 二级页 锻炼列表页
     */
    @GetMapping("/query-exercise-list")
    public AjaxResult queryExerciseList(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("锻炼列表页: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return secondService.queryExerciseList(secondDTO);
    }

    /**
     * 三级页 详情信息
     */
    @GetMapping(value = "/query-exercise-detail/{id}")
    public AjaxResult queryExerciseDetail(@PathVariable("id") Long id)
    {
        return AjaxResult.success(secondService.queryExerciseDetail(id));
    }
    /**
     * 三级页 平均心率
     */
    @GetMapping(value = "/query-exercise-heart-rate/{id}")
    public AjaxResult queryExerciseHeartRate(@PathVariable("id") Long id)
    {
        return AjaxResult.success(secondService.queryExerciseHeartRate(id));
    }

    /**
     * 三级页 心率区间
     */
    @GetMapping(value = "/query-exercise-interval/{id}")
    public AjaxResult queryExerciseInterval(@PathVariable("id") Long id)
    {
        return AjaxResult.success(secondService.queryExerciseInterval(id));
    }



}
